"""
@Time ： 2022/9/7 9:34
@Auth ： 陈杰 200320501042
@E-mail : 1612845322@qq.com
"""
import random
# break和continue语句的使用
# 初始化要填词的成语
words = ["春暖花开","十字路口","千军万马","白手起家","张灯结彩","风和日丽","万里长城",
        "人来人往","自由自在","瓜田李下","助人为乐","白手起家","红男绿女","春风化雨",
        "马到成功","拔苗助长","安居乐业","走马观花","念念不忘","落花流水","张灯结彩",
        "一往无前","落地生根","天罗地网","东山再起","一事无成","山清水秀",
        "别有洞天","语重心长","水深火热","鸟语花香","自以为是"]
# 初始化回答正确和回答错误的题的数量
right = 0
wrong = 0
# 记录积分的变量count初始值为20
count = 20
print('直接填写答案，回车进入下一关。什么也不填忽略本成语！！')
while True:
    # 随机选择一条成语
    word = random.choice(words)
    # 在成语种随机选择填空位置
    bank = random.randint(0, 3)
    # 产生带空格的成语
    new = word[:bank] + "___" + word[bank + 1:]
    # 输出带空格的成语
    print(new)
    # 输入空格中需要填入的字
    num = input("输入:")
    # 输入q表示终止答题
    if num == 'q':
        print("终止答题")
        # 退出循环
        break
    if not num:
        print("过！")
        # 结束本次循环重新开始下一次循环
        continue
    # 如果填入的词正确
    elif num.strip(" ") == word[bank]:
        # 积分加2分
        count += 2
        # 正确题数+1
        right += 1
        # 打印正确，你真棒！
        print("正确，你真棒！")
    # 否则表示答错
    else:
        # 积分减去2分
        count -= 2
        # 错误题数+1
        wrong += 1
        # 打印回答错误，正确答案是
        print("错了，正确答案：", word[bank])
    print(
        "选手答对：%d题,答错：%d题,正确率为：%.2f%%,最后得分为:%d" %
        (right, wrong, right * 100 / (right + wrong), count))